package com.liu.config;

import com.liu.config.Interceptor.JwtInterceptor;
import com.liu.config.Interceptor.PhyInterceptor;
import com.liu.config.Interceptor.UserInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class InterceptorConfig implements WebMvcConfigurer {

    @Override
    public void addInterceptors(InterceptorRegistry registry) {

//        registry.addInterceptor(jwtInterceptor())
//                .addPathPatterns("/**")   //拦截所有请求，通过判断token是否合法来决定
//                .excludePathPatterns(
//                        "/**/login", "/**/register","/**/export","/**/import","/file/**","/**/token",
//                        "/department/list","/department/findDep",
//                        "/physician/selectPhyByDep","/physician/findDep","/physician/findPhyByDepId","/physician/findPhy","/physician/findByName","/physician/findById"
//                        ,"/information/list","/area/findPro","/information/findById",
//                        "/hospital/findHosByProvince","/hospital/findById","/hospital/findHosByDep","/hospital/findHos",
//                        "/province/list",
//                        "/disease/findById",
//                        "/appraise/phyAppraise","/appraise/userAppraise","/appraise/edit","/appraise/findPhy","/appraise/findUser","/appraise/del","/appraise/delBatch",
//                        "/stage/findStageByPhy","/stage/findStage","/stage/edit","/stage/del","/stage/delBatch",
//                        "/question/list","/question/edit","/question/findQueByUser","question/findById","/question/list",
//                        "/area/findCity",
//                        "/order/personOrder","/order/updateStage","/order/delBatch","/order/phyOrder","/order/edit","/order/del");
//
//        registry.addInterceptor(userInterceptor())
//                .addPathPatterns("/**")
//                .excludePathPatterns(
//                        "/**/login", "/**/register","/**/export","/**/import","/file/**","/**/token",
//                        "/department/list","/department/findDep",
//                        "/physician/selectPhyByDep","/physician/findDep","/physician/findPhyByDepId","/physician/findPhy","/physician/findByName","/physician/findById"
//                        ,"/information/list","/area/findPro","/information/findById",
//                        "/hospital/findHosByProvince","/hospital/findById","/hospital/findHosByDep","/hospital/findHos",
//                        "/province/list",
//                        "/disease/findById",
//                        "/appraise/phyAppraise","/appraise/userAppraise","/appraise/edit","/appraise/findPhy","/appraise/findUser","/appraise/del","/appraise/delBatch",
//                        "/stage/findStageByPhy","/stage/findStage","/stage/edit","/stage/del","/stage/delBatch",
//                        "/question/list","/question/edit","/question/findQueByUser","question/findById","/question/list",
//                        "/area/findCity",
//                        "/order/personOrder","/order/updateStage","/order/delBatch","/order/phyOrder","/order/edit","/order/del"
//                );

//        registry.addInterceptor(phyInterceptor())
//                .addPathPatterns("/**")
//                .excludePathPatterns(
//                        "/**/login", "/**/register","/**/export","/**/import","/file/**","/**/token",
//                        "/department/list","/department/findDep",
//                        "/physician/selectPhyByDep","/physician/findDep","/physician/findPhyByDepId","/physician/findPhy"
//                        ,"/information/list","/area/findPro","/information/findById",
//                        "/hospital/findHosByProvince","/hospital/findById","/hospital/findHosByDep","/hospital/findHos",
//                        "/province/list",
//                        "/disease/findById",
//                        "/appraise/phyAppraise","/appraise/userAppraise","/appraise/edit","/appraise/findPhy","/appraise/findUser","/appraise/del","/appraise/delBatch",
//                        "/stage/findStageByPhy",
//                        "/question/list","/question/edit","/question/findQueByUser",
//                        "/area/findCity",
//                        "/order/personOrder","/order/updateStage","/order/delBatch"
//                );


        /*"/stage/findStage","/stage/edit","/stage/del","/stage/delBatch",
        "/order/phyOrder","/order/edit","/order/del","/order/delBatch","/physician/findByName"

        */

    }

    @Bean
    public JwtInterceptor jwtInterceptor() {
        return new JwtInterceptor();
    }
    @Bean
    public UserInterceptor userInterceptor() {
        return new UserInterceptor();
    }
    @Bean
    public PhyInterceptor phyInterceptor() {
        return new PhyInterceptor();
    }
}
